package csc.fresher.app;

import java.sql.Time;
import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import csc.fresher.dao.SavingAccountDao;
import csc.fresher.dao.impl.DepositAccountTransactionDaoImpl;
import csc.fresher.entity.DepositTransaction;

@Service
@Scope("request")
public class MainService {
	
	@Autowired
	SavingAccountDao savingAccountDao;
	@Autowired
	DepositAccountTransactionDaoImpl transactionDao;
	
	private String name;
	
	public String getName() {
		test();
		return "abxc";
	}

	public void setName(String name) {
		this.name = name;
	}

	public void test(){
		//byte a = 1;
		//SavingAccount savingAccount = new SavingAccount(12L, a, 12000, true, new Date(System.currentTimeMillis()), AccountState.NEW, 123456789000L);
		
		//savingAccountDao.create(savingAccount);
		//Timestamp currentTimestamp = new Timestamp(System.currentTimeMillis());
		//Transaction tx = new Transaction(100D, currentTimestamp, currentTimestamp, TransactionType.WiTHDRAW, 223456789001L, BankingConstant.DEFAULT_DEPOSIT_ACCOUNT_ID, TransactionState.HOLD, 1000D, 900D, 223456789000L, 30000L, BankingConstant.DEFAULT_DEPOSIT_ACCOUNT_ID);
		
		//int returnId = transactionDao.createTransaction(tx);
		//transactionDao.approveTransaction(13, 1, 223456789001L);
		List<DepositTransaction> list = transactionDao.searchTransactionByCustomerCardIDInGivenPeriod(123456789, Timestamp.valueOf("2014-03-11 14:17:58"), Timestamp.valueOf("2014-03-14 14:17:58"));
		for(DepositTransaction t: list){
			System.out.println(t.getTransactionID() + " " + t.getAfterBalance());
		}
		
	}
}
